<?php

namespace App\Http\Controllers\Agency;
use App\Services\ProductService;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use hg\apidoc\annotation as Apidoc;

/**
 * 产品套餐
 * @Apidoc\Group("service")
 */

class ProductController extends Controller
{
    /**
     * @Apidoc\Title ("产品套餐-套餐列表(不带分页)")
     * @Apidoc\Url("/agency/getProductList")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Returned("id",type="int",require=false,desc="列表id"),
     * @Apidoc\Returned("name",type="object",require=false,desc="套餐名称"),
     * @Apidoc\Returned("price",type="object",require=false,desc="套餐价格"),
     * @Apidoc\Returned("days",type="string",require=false,desc="套餐服务天数"),
     * @Apidoc\Returned("nums",type="int",require=false,desc="套餐约见人数"),
     * @Apidoc\Returned("status",type="string",require=false,desc="套餐状态Y启用N禁用"),
     * @Apidoc\Returned("remark",type="string",require=false,desc="套餐备注"),
     * @Apidoc\Returned("created_at",type="string",require=false,desc="套餐创建时间"),
     **/
    public function getProductList(Request $request , ProductService $productService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $productService->getProductList($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("产品套餐-套餐列表(带分页)")
     * @Apidoc\Url("/agency/productList")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("page",type="int",require=false,desc="页数"),
     * @Apidoc\Param("pageSize",type="object",require=false,desc="每页条数"),
     * @Apidoc\Returned("id",type="int",require=false,desc="列表id"),
     * @Apidoc\Returned("name",type="object",require=false,desc="套餐名称"),
     * @Apidoc\Returned("price",type="object",require=false,desc="套餐价格"),
     * @Apidoc\Returned("days",type="string",require=false,desc="套餐服务天数"),
     * @Apidoc\Returned("nums",type="int",require=false,desc="套餐约见人数"),
     * @Apidoc\Returned("status",type="string",require=false,desc="套餐状态Y启用N禁用"),
     * @Apidoc\Returned("remark",type="string",require=false,desc="套餐备注"),
     * @Apidoc\Returned("created_at",type="string",require=false,desc="套餐创建时间"),
     **/
    public function productList(Request $request , ProductService $productService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $productService->productList($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("产品套餐-更新状态")
     * @Apidoc\Url("/agency/productStatusUpdate")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("id",type="int",require=true,desc="列表id")
     * @Apidoc\Param("status",type="string",require=true,desc="Y启用；N禁用")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */

    public function productStatusUpdate(Request $request , ProductService $productService)
    {
        $params = $request->input();
        $result = $productService->productStatusUpdate($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    /**
     * @Apidoc\Title ("产品套餐-保存套餐")
     * @Apidoc\Url("/agency/productUpdate")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param ("giftname",type="int",desc="礼物名称")
     * @Apidoc\Param("url",type="string",desc="礼物图片链接")
     * @Apidoc\Param("fee",type="string",desc="单价")
     * @Apidoc\Param("income",type="string",desc="礼物积分")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function productUpdate(Request $request , ProductService $productService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $productService->productUpdate($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }
}
